home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / ubas830.zip / MALM.EXE / TSTPRM.UB < prev    next >
Text File  |  1990-08-22  |  783b  |  17 lines

  1.    10   *TestPrime(N,&Ans)
  2.    20   ' Primality test for numbers less than 50 billion(U.S.).  Returns 1
  3.    30   ' for prime, 0 for composite (or 1) and -1 for error (out of range).
  4.    40   ' 21 May 1990
  5.   100   local Mc,Mb,Ma,A,B,C
  6.   110   N=abs(N)
  7.   120   if or{N=0,N>50000000000} then Ans=-1:return endif
  8.   130   if N<131072 then if N=nxtprm(N-1) then Ans=1 else Ans=0 endif
  9.   140   :return endif
  10.   170   if fnSpspt(N,2)=0 then Ans=0:return endif
  11.   180   gosub *Perrin(N,&Mc,&Mb,&Ma,&A,&B,&C)
  12.   190   if or{B<>0,Mb<>(N-1)} then Ans=0:return endif
  13.   200   if or{N=27664033,N=1235188597,N=14735895301} then Ans=0:return endif
  14.   210   if Or[N=19267579361,N=39675460001,N=43522383061} then Ans=0
  15.   220   :return endif
  16.   230   Ans=1:return ' End of subroutine TestPrime.
  17.